﻿@using AncientLand.Common
@model AncientLand.Service.Entity.Pager<AncientLand.Service.Entity.WeddingCategory>
@{    
    Layout = "~/Views/Shared/_AdminLayoutPage.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<div class="grid_16 widget tabs first">
    <div class="widget_title clearfix">
        <h2>
            婚纱作品分类</h2>
        <ul class="sf-menu">
            <li><a id="Add" class="btn blue right medium" href="#" title="新增写真作品分类" style="box-shadow:none">
                <span>新增婚纱作品分类</span></a>
                <div id="AddDiv" class="grid_8 widget" style="margin: 0px;top: 25px; left: -345px;display: none; position: absolute; z-index: 100">                            
                            <div class="widget_body" >
                                <div class="widget_content">
                                    <div class="msg notice">
                                        <span>请填写作品分类名称，并确保在20个字符内.</span> <a class="close" href="#" style="margin:0px;padding:0px">x</a>
                                    </div>
                                    <form id="AddForm" name="AddForm" action="@Url.Content("~/WeddingAdmin/WeddingCategoryAdd")" method="post">
                                    <label class="block" style="margin-bottom: 10px;">
                                        写真作品分类名称:</label>
                                    <input type="text" class="large" id="txtCategoryName" name="txtCategoryName" maxlength="25" />
                                     
                                    <label class="block" style="margin-top: 10px;">
                                        <a class="btn grey left" id="aClose"><span>【取 消】</span></a>                                         
                                        <a class="btn blue right" id="btnSubmit" ><span>【保 存】</span></a>
                                    </label>
                                    </form>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                        </div>
            </li>
        </ul>
    </div>
    <div class="widget_body">
        <div class="widget_content">
            <ul class="gallery">
                @foreach (var item in Model.DataSource)
                {
                    <li><a href="@Url.Content("~/WeddingAdmin/ShowWeddingCategory?id=" + @item.Id + "&name=" + Url.Encode(@item.Name))" class="gallerythumb" title="@item.Name">
                        <img src="@Url.Content("~" + item.ThumbnailPath)" alt="@item.Name" /></a>
                        
                        <ul class="img_options">
                            <li><a href="@Url.Content("~/WeddingAdmin/ShowWeddingCategory?id=" + @item.Id + "&name=" + Url.Encode(@item.Name))" class="btn">查看</a></li>
                            <li><a href="@Url.Content("~/WeddingAdmin/DeleteWeddingCategory?id=" + @item.Id + "&name=" + Url.Encode(@item.Name))" class="btn" data="delete">
                                删除</a></li>
                        </ul>
                        <p class="center" style="margin:0px"><a href="@Url.Content("~/WeddingAdmin/ShowWeddingCategory?id=" + @item.Id + "&name=" + Url.Encode(@item.Name))" >@item.Name</a></p>
                    </li>
                }
            </ul>
            <div class="clear">
            </div>
        </div>
        @Html.Partial("_AdminPager", Model.Item)
    </div>
</div>
<div class="clear">
</div>
<script type='text/javascript'>
    $(document).ready(function () {
        $(".gallerythumb").bind("mouseenter", function () {
            $(".gallerythumb .btn").hide();
            $(this).parent().find(".btn").show();
        });
        $(".gallery").bind("mouseleave", function () {
            $(this).parent().find(".btn").hide();
        });
        $("a[rel^='prettyPhoto']").prettyPhoto({
            opacity: 0.9,
            show_title: true,
            social_tools: false
        });

        $("<span class='newcover'></span>").appendTo($(".gallery li").eq(0));
        $("<span class='newcover'></span>").appendTo($(".gallery li").eq(0).next());

        $(".gallery li a.btn[data='delete']").click(function () {
            return confirm("删除分类会同时删除该分类下的所有图片，确定真的要删除吗？");
        })

        $("#Add").click(function () {
            $('#AddDiv').toggle();
            return false;
        })

        $("#aClose").click(function () {
            $('#AddDiv').toggle();
            return false;
        })

        $("#AddForm").validate({
            rules: {
                txtCategoryName: {
                    required: true,
                    maxlength: 20
                }
            },
            messages: {
                txtCategoryName: {
                    required: "请输入分类名称.",
                    maxlength: jQuery.format("分类名称必须小于{0}个字符.")
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo($(element).next());
                //$(error).parent(0).css("visibility", "visible");
            },
            submitHandler: function (form) {
                form.submit();
            },
            success: function (label) {
                label.html("&nbsp;").addClass("checked"); // set &nbsp; as text for IE
            }

        });

        $("#btnSubmit").click(function () { $("#AddForm").submit(); });

    });
</script>
